<!DOCTYPE html>
<html>

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0">
    <title>重置密码 - {$Think.config.basic.site_title}</title>

    <link href="__STATIC__/css/login.css" rel="stylesheet" type="text/css">
    <script type="text/javascript" src="__STATIC__/js/jquery.js"></script>
    <script src="__STATIC__/js/common.js"></script>
    <script src="__STATIC__/js/layer.js"></script>
</head>

<body>
<div class="top">
    <div class="d1">
        <div class="d11" style="background-image: url({$Think.config.basic.site_logo});height: 18px; background-repeat: no-repeat; background-position: 15px 5px;">
            <a href="{:url('index/index')}" class="d7">会分享有收获</a>
        </div>
    </div>
</div>
<div class="pc"></div>
<span class="bg"></span>

<div class="p9">
    <div class="p5"> </div>
    <div class="p6">为用户而变革，越简单越好，越快越好 ！</div>
    <div class="p4">会分享，就会有收获！</div>

    <div class="p1" style="margin-top: 15px;box-shadow: none;">
        <!-- 注册账号 -->
        <div id="reg">
            <span class="main-title">设置密码</span>
            <form onkeydown="if(event.keyCode==13){doReg();return false;}">

                <br>

                <div class="p3 pmob2">
                    <input class="input" id="reg_pwd" type="text" value="" tabindex="3" maxlength="64" placeholder="设置密码">
                </div>

                <div class="p3 pmob2">
                    <input class="input" id="reg_repwd" type="text" value="" tabindex="3" maxlength="64" placeholder="再次填写密码">
                </div>

                <div class="p3">
                    <div class="errorBox">请设置密码</div>
                </div>

                <div class="p3"></div>
            </form>

            <div class="p3">
                <input onclick="doForget()" class="btn" type="submit" tabindex="4" value="设置密码">
            </div>

        </div>

    </div>

    <script>

        //提交注册
        function doForget()
        {

            var pwd = $("#reg_pwd").val();
            var repwd = $("#reg_repwd").val();

            var msg = '';

            if(!pwd){
                $('#reg_pwd').focus();
                msg = "请设置密码";
            }

            if(!repwd){
                $("#reg_repwd").focus();
                msg = "请再次填写密码";
            }

            if(pwd !== repwd){
                $('#reg_pwd').focus();
                msg = "两次输入密码不一致";
            }

            if(msg != ''){
                return error(msg);
            }

            //提交注册
            $.ajax({
                type: "post",
                url : "{:url('user/reset')}?key={$key}&sign={$sign}",
                data: {
                    "pwd":pwd
                },
                dataType:'json',
                success: function(data){
                    if (data.code == 1) {
                        ok(data.msg);
                    } else {
                        error(data.msg);
                    }
                },
                error: function (error) {
                    layer.alert("API请求失败，请联系客服",{icon:2});
                }
            });
        }

        //成功
        function ok(msg)
        {
            layer.msg(msg,{icon:1},function(){
                window.location.href = "{:url('user/login')}"
            });
        }

        //失败
        function error(msg)
        {
            $(".errorBox").html(msg);
            $(".errorBox").show();
        }
    </script>
</div>

<div class="copyright">不得利用云存储发布，存储，传播违法信息</div>
<div class="foot_info"> © 2021 {$Think.config.basic.site_title}    </div>
</body>
</html>